package com.learning.railwayreservation.biz;

import java.util.ArrayList;
import java.util.List;

import com.learning.railwayreservation.dao.BookingDao;
import com.learning.railwayreservation.dao.CheckTicketsAvailibiltyDao;

import com.learning.railwayreservation.vo.AvailabilityDetailsVo;
import com.learning.railwayreservation.vo.BookingInputVO;
import com.learning.railwayreservation.vo.BookingOutputVO;
import com.learning.railwayreservation.vo.CheckTicketsAvailibiltyInputVO;
import com.learning.railwayreservation.vo.PassengerVO;
import com.learning.railwayreservation.vo.TicketVO;

public class Booking {
	/*
	 * public static void main(String args[]) { Booking booking = new Booking();
	 * System.out.println("\nhere is the result\n");
	 * System.out.println("\nticket info\n"); BookingInputVO availibility2VO =
	 * new BookingInputVO(); availibility2VO.setSeatId(4);
	 * availibility2VO.setFirstName("richa");
	 * availibility2VO.setLastName("ganjoo"); availibility2VO.setAge(25);
	 * availibility2VO.setSex("F"); booking.bookTicket(availibility2VO); }
	 * 
	 */

	public static void main(String args[]) {
		Booking booking = new Booking();
		System.out.println("\nhere is the result\n");
		System.out.println("\nticket info\n");

		List<PassengerVO> bList = new ArrayList<PassengerVO>();
		TicketVO ticketVO = new TicketVO();

		PassengerVO availibility2VO = new PassengerVO();
		availibility2VO.getSeatVo().setUniqueSeatId(19);
		availibility2VO.setFirstName("richa");
		availibility2VO.setLastName("ganjoo");
		availibility2VO.setAge(25);
		availibility2VO.setSex("F");
		bList.add(availibility2VO);
		
		availibility2VO = new PassengerVO();
		availibility2VO.getSeatVo().setUniqueSeatId(20);
		availibility2VO.setFirstName("Ramit");
		availibility2VO.setLastName("ganjoo");
		availibility2VO.setAge(25);
		availibility2VO.setSex("M");
		bList.add(availibility2VO);

		ticketVO.setPassengerList(bList);
		booking.bookTickets(ticketVO);

	}

	// public List<BookingOutputVO> bookTicket(BookingInputVO bookingInputVO) {
	//
	// BookingDao dao = new BookingDao();
	// List<BookingOutputVO> testList = dao.testResultSet(bookingInputVO);
	// for (BookingOutputVO bookingOutputVO : testList) {
	//
	// System.out.print("\nTrain Name:" + bookingOutputVO.getTrainName());
	// System.out.print(" Boggie id:" + bookingOutputVO.getBoggieId());
	// System.out.print(" Row id:" + bookingOutputVO.getRowId());
	// System.out.print(" Seat id:" + bookingOutputVO.getSeatId());
	// System.out.print(" unique Seat id:"
	// + bookingOutputVO.getUniqueSeatId());
	// System.out.print(" first name:" + bookingOutputVO.getFirstName());
	// System.out.print(" last name:" + bookingOutputVO.getLastName());
	// System.out.print(" age:" + bookingOutputVO.getAge());
	// System.out.print(" sex:" + bookingOutputVO.getSex());
	// System.out.print("\n");
	//
	// }
	// return testList;

	// }

	public TicketVO bookTickets(TicketVO ticket) {

		BookingDao dao = new BookingDao();
		TicketVO ticketVo = dao.bookTickets(ticket);
		System.out.println("Train Name:" + ticketVo.getTrainName());
		System.out.println("Train Id:" + ticketVo.getTrainId());
		System.out.println("Class:" + ticketVo.getBoggieClass());
		System.out.println("Date:" + ticketVo.getArrivalTime());
		List<PassengerVO> passengerList = ticketVo.getPassengerList();
		for (PassengerVO passengerVo : passengerList) {
			System.out.print("     Boggie id:"
					+ passengerVo.getSeatVo().getBoggieId());
			System.out
					.print("    Row id:" + passengerVo.getSeatVo().getRowId());
			System.out.print("     Seat id:"
					+ passengerVo.getSeatVo().getSeatId());
			System.out.print("  unique Seat id:"
					+ passengerVo.getSeatVo().getUniqueSeatId());
			System.out.print("  first name:"
					+ passengerVo.getFirstName());
			System.out.print("  last name:" + passengerVo.getLastName());
			System.out.print("  age:" + passengerVo.getAge());
			System.out.print("  sex:" + passengerVo.getSex());
			System.out.print("\n");

		}
		return ticketVo;

	}

}